package com.bt.springboot.common.util;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;


/**
 * @author zkx
 * @Date 2024/1/6 16:44
 */
public class RabbitMqUtils {

	public static Channel getChannel() throws Exception {
		// 创建一个链接工厂
		ConnectionFactory connectionFactory = new ConnectionFactory();
		// 连接IP 连接RabbitMQ的队列
		connectionFactory.setHost("localhost");
		// 用户名
		connectionFactory.setUsername("root");
		// 密码
		connectionFactory.setPassword("123456");
		// 创建连接
		Connection connection = connectionFactory.newConnection();
		// 获取信道
		return connection.createChannel();
	}
}
